from django.shortcuts import render
from django.http import HttpResponse
from movies import  models
from .services import insert_movie
from .services import  get_movies
from .services import insert_movie_by_user
# import services
# # Create your views here.
#
#
def insert(request):
    insert_movie()
    return HttpResponse({'res':'插入成功'})


def debugs(request):
    print(request.GET)
    return HttpResponse(request.GET)

def insert_by_user(request):
    name = request.GET.get('name')
    price = request.GET.get('price')
    score = float(request.GET.get('score'))
    print(score)
    insert_movie_by_user(name,score,price)
    return HttpResponse('插入成功')



def get_douban(request):
    # res = models.DoubanModel.objects.values()
    res = models.movie.objects.values()
    print(type(res))
    if res:
        return HttpResponse(res)
    else:
        return HttpResponse('没有数据！')

def get(request):
    res = get_movies()
    print(list(res))
    return HttpResponse(res)




